package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.ActivateDTO;
import com.heima.model.user.dtos.LoginDTO;
import com.heima.user.service.ApUserLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "app端用户登录api", tags = "app端用户登录api")
@RestController
@RequestMapping("/api/v1/login")
public class ApUserLoginController {

    @Autowired
    ApUserLoginService apUserLoginService;


    @ApiOperation("请求发送验证码")
    @PostMapping("/send_Code")
    public ResponseResult sendCode(@RequestBody LoginDTO dto) {
        return apUserLoginService.sendCode(dto);
    }

    @ApiOperation("密码登录")
    @PostMapping("/login_auth")
    public ResponseResult login(@RequestBody LoginDTO dto) {
        return apUserLoginService.login(dto);
    }

    @ApiOperation("申请激活账号")
    @PostMapping("/registerAllow")
    public ResponseResult registerAllow(@RequestBody ActivateDTO dto) {
        return apUserLoginService.sendMineMail(dto);
    }

    @ApiOperation("确认激活账号")
    @GetMapping("/Confirm/{phone}")
    public ResponseResult Confirm(@PathVariable("phone") String phone) {
        return apUserLoginService.updateUserStatus(phone);
    }


}